<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="com.biz.conf.Global" %>
<%@ include file="/jsp/taglib.jsp"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path+ "/";
%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">

    <link href="${ctxStatic}/plugins/h+/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/plugins/h+/css/plugins/webuploader/webuploader.css">
    <link href="${ctxStatic}/plugins/h+/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

    <link href="${ctxStatic}/plugins/h+/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/colorpicker/css/bootstrap-colorpicker.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/cropper/cropper.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/switchery/switchery.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/nouslider/jquery.nouislider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/animate.min.css" rel="stylesheet">
    <link href="${ctxStatic}/plugins/h+/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <link href="${pageContext.request.contextPath}/resources/plugins/h+/css/plugins/jsTree/style.min.css" rel="stylesheet">
    <style>
        .ml10 {
            margin-left: 15px;
        }
        .chosen-container{
                width:100% !important;
            }

    </style>

</head>

<body class="gray-bg" >

<div class="panel blank-panel">
    <div class="panel-heading">
        <div class="panel-options">
            <ul class="nav nav-tabs">
                    <li class="active" style="width:50%;"><a data-toggle="tab" href="tabs_panels.html#tab-1"><i class="fa fa-user"></i>系统用户</a>
                    </li>
            </ul>
        </div>
    </div>

    <div class="panel-body">
        <div class="tab-content">
                <div id="tab-1" class="tab-pane active">
                    <div class="wrapper wrapper-content  animated fadeInRight" id="ccbb">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="toolbar">
                                    <div id="toolbar">
                                            <button id="btn_add" class="btn btn-primary"><i class="fa fa-plus-circle"></i>&nbsp;新增</button>
                                    </div>
                                </div>
                                    <span id="spancc" class="spancc"></span>
                                    <div class="row">
                                        <div class="ibox float-e-margins">
                                            <div class="ibox-title">
                                                <h5>搜索条件</h5>
                                                <div class="ibox-tools">
                                                    <a class="collapse-link">
                                                        <i class="fa fa-chevron-up"></i>
                                                    </a>
                                                </div>
                                            </div>
                                            <div class="ibox-content" >
                                                <div class="row">
                                                    <div class="col-md-2"><input placeholder="登录名" id="q_login_name" class="form-control" ></div>
                                                    <div class="col-md-2"><input placeholder="姓名" id="q_person_name" class="form-control" ></div>
                                                    <div class="col-md-1"><button id="btn_search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;搜索</button></div>

                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <table id="exampleTablePagination"></table>
                        </div>
                    </div>
                    </div>
                </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal inmodal" id="IssuedGiftModal" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <div class="modal-header">
                <span style="font-size:18px;">远程发券</span>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body">
                <form name="">
                    <div class="form-group"><label>电话：</label>
                        <input type="hidden" id="txt_phone" value="" />
                        <label id="lbl_phone"></label></div>
                    <div><label>券额(元)：</label>
                        <input type="text" maxlength="6" id="txt_gift_total" value="" style="width:80%" class="form-control" /></div>
                    <div><label>备注：</label>
                        <textarea id="txt_gift_remark" rows="3" cols="20" style="width:80%" class="form-control"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="doSave();">确定</button>
            </div>
        </div>
    </div>
</div>

<div class="modal inmodal" id="ModifyRoleModal" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <div class="modal-header">
                <span style="font-size:18px;">修改权限</span>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            </div>
            <div class="modal-body">
                <div class="ibox-content">
                    <div id="roleJson">
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <input type="hidden" value="" id="roleHidden"/>
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="doRoleSave();">确定</button>
            </div>
        </div>
    </div>
</div>
    <script src="${ctxStatic}/plugins/h+/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctxStatic}/plugins/h+/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/bootstrap-table.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/locale/bootstrap-table-zh-CN.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/export/bootstrap-table-export.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/bootstrap-table-master/extensions/editable/bootstrap-table-editable.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/content.min.js?v=1.0.0"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="${ctxStatic}/plugins/h+/js/plugins/layer/laydate/laydate.js"></script>
    <script>

    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
        <script type="text/javascript">
            //初始化表格对象
            var $table = $('#exampleTablePagination');
            /*
                获取选中行的相关数据
            */
            $(function () {
                $table.on('click-row.bs.table', function (e, row, $element) {
                    $('.success').removeClass('success');
                    $($element).addClass('success');
                });
                $('#button').click(function () {
                    alert('Selected name: ' + getSelectedRow().customer);
                });
                $('#user_balanceType').chosen({
                    no_results_text : "未找到此选项!",
                    width:"100%"
                });
            });
            function getSelectedRow() {
                var index = $table.find('tr.success').data('index');
                return $table.bootstrapTable('getData')[index];
            }

            /*
               操作按钮的初始化
            */
            /*function userOperation(value, row, index) {
                return [
                        '<a class="like" href="javascript:void(0)" title="喜好">',
                                '<i class="glyphicon glyphicon-heart"></i>',
                                '</a>',
                                '<a class="edit ml10" href="javascript:void(0)" title="编辑">',
                                '<i class="glyphicon glyphicon-edit"></i>',
                                '</a>',
                                '<a class="remove ml10" href="javascript:void(0)" title="删除">',
                                '<i class="glyphicon glyphicon-remove"></i>',
                                '</a>'
                        ].join('');
            }
            //每个按钮对应的事件
            window.actionEvents = {
                'click .like': function (e, value, row, index) {
                    alert('You click like icon, row: ' + JSON.stringify(row));
                },
                'click .edit': function (e, value, row, index) {
                    //弹出编辑层
                    showPopup();
                },
                'click .remove': function (e, value, row, index) {
                    alert('You click remove icon,: ' + JSON.stringify(row));

                }
            };*/

            /*
                每一列详情格式化数据
             */
            function formDetail(index, row) {
                return row.customer+index;
            }


            function showPopup(user_code){
                    //自定页
                    parent.layer.open({
                        type: 2,
                        shift:4,//动画类型
                        moveType:1,
                        maxmin: true,
                        shadeClose: true, //开启遮罩关闭
                        area: ['800px', '530px'],
                        content: '${pageContext.request.contextPath}/sysUser/toEdit.ac?userCode='+user_code,
                        success: function(layero, index){
                            //layer.title("888888888", index);
                            var datas={"firstname":"555555"};
                            var body = layer.getChildFrame('body', index);
                            //var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                            console.log(body.html()); //得到iframe页的body内容
                            $table.bootstrapTable('refresh');
                        },
                        cancel: function(index){
                           // alert(index);
                            return true;
                        },
                        close  : function(index){

                            $table.bootstrapTable('refresh', queryParams);
                        },
                        end : function(index){
                            $table.bootstrapTable('refresh', queryParams);
                        }
                    });
                $table.bootstrapTable('refresh');
            }

            ////////////////////////////////////////////////////////////////////////////////////////以下是通过js方式初始化BootStrapTable/////////////////////////////////////////////

            $table.bootstrapTable({
                url: "${pageContext.request.contextPath}/sysUser/showSysUserGrid.ac",
                method: 'post',
                contentType: "application/x-www-form-urlencoded",//必须的
                dataType: "json",
                pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
                height: ($(window).height()) ,
                //cardView:true,//是否自适应手机
                pagination: true, //分页
               // queryParamsType: "limit",
                singleSelect: false,
                cache:false,
                sortName:"customer",
                search: false, //显示搜索框
                showColumns:false,
                showRefresh:false,
                showToggle:false,
                showPaginationSwitch:false,
                smartDisplay:true,
                detailView:false,
                toolbar:"#toolbar",
                queryParams: queryParams,//参数
                searchOnEnterKey:true,
                detailFormatter:function(index, row, element){
                    return row.customer;
                },
                sidePagination: "server", //服务端处理分页
                columns: [
                {
                    visible:false,
                    field:'id'
                },
                {
                    title:'选择',
                    align:'center',
                    formatter:stateFormatter,
                    checkbox:true
                },
                {
                    title: '登录名',
                    field: 'loginName',
                    titleTooltip: '点击可以进行排序操作',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '姓名',
                    field: 'personName',
                    sortStable:true,
                    align: 'center'
                },
                {
                    title: '权限',
                    field: 'roleName',
                    formatter:function (value, row, index) {
                            return row.roleName+'&nbsp;&nbsp;<a onclick="modifyRole(\''+row.id+'\')" href="javascript:void(0);">修改</a>';
                    }
                },
//                {
//                    title: '用户类型',
//                    field: 'identity',
//                    formatter:function (value, row, index) {
//                        if(row.identity==1)
//                        {
//                            return "管理员";
//                        }else if(row.identity==2)
//                        {
//                            return "代理商";
//                        }else if(row.identity==3)
//                        {
//                            return "商户";
//                        }else if(row.identity==4)
//                        {
//                            return "门店";
//                        }
//                    }
//                },
                {
                    title: '邮箱',
                    field: 'email',
                    align: 'center'
                },
                {
                    title: '手机',
                    field: 'phone',
                    align: 'center'
                },{
                    title: '锁定',
                    formatter:function (value, row, index) {
                        var locktemp='';
                        lockId="lock"+row.id;
                        row.isLock==0?locktemp='<input type="checkbox" onclick="doLock(this,\''+ row.id +'\')"  class="onoffswitch-checkbox" id="'+lockId+'">':
                                locktemp='<input type="checkbox" checked onclick="doLock(this,\''+ row.id +'\')" class="onoffswitch-checkbox" id="'+lockId+'">';
                        var temp='<div class="switch">'+
                                '<div class="onoffswitch">'+locktemp+
                                '<label class="onoffswitch-label" for="'+lockId+'">'+
                                '<span class="onoffswitch-inner"></span>'+
                                '<span class="onoffswitch-switch"></span>'+
                                '</label>'+
                                '</div>'+
                                '</div>';
                        return temp;
                    },
                    align: 'center'
                },
                {
                    title: '操作',
                    align: 'center',
                    events:{
                       /* 'click .like': function (e, value, row, index) {
                            alert('You click like icon, row: ' + JSON.stringify(row));
                        },*/
                        'click .edit': function (e, value, row, index) {
                            // alert('You click edit icon, row: ' + JSON.stringify(row));
                            //弹出编辑层
                            showPopup(row.id);
                        },
                        'click .remove': function (e, value, row, index) {
                            var arr=[row.id];
                            deleteGrid(arr);
                        }
                    },
                    formatter:function(value,row,index){
                        return [
                            /*'<a class="like" href="javascript:void(0)" title="喜好">',
                            '<i class="glyphicon glyphicon-heart"></i>',
                            '</a>',*/
                            '<a class="edit ml10" href="javascript:void(0)" title="编辑">',
                            '<i class="glyphicon glyphicon-edit"></i>',
                            '</a>',
                            '<a class="remove ml10" href="javascript:void(0)" title="删除">',
                            '<i class="glyphicon glyphicon-remove"></i>',
                            '</a>'
                        ].join('');
                    }
                }
            ]
            });

            /*
                搜索按钮
            */
            $("#btn_search").click(function(){
                $table.bootstrapTable('selectPage', 1);
                $table.bootstrapTable('refresh', queryParams);
            });

            /*
                传递的参数
            */
            function queryParams(params) {
                var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    limit: params.limit,  //页面大小
                    offset: params.offset, //页码
                    pageindex:params.pageNumber,
                    login_name: $("#q_login_name").val(),
                    person_name: $("#q_person_name").val()
                };
                return temp;
            }
            ///////////////////////////////////////////////////////////////toolbar///////////////////////////////////////
            //新增
            $("#btn_add").click(function(){
                showPopup("");
            });

            //批量删除
            $("#btn_del").click(function(){
                var ids=getSelections();
                //执行批量删除
                deleteGrid(ids);
            });

            /*
                批量删除方法体
             */
            function deleteGrid(ids){
                if(ids.length>0){
                    swal({
                        title: "您确定要删除这些信息吗",
                        text: "删除后将无法恢复，请谨慎操作！",
                        type: "warning",
                        showCancelButton: true,
                        confirmButtonColor: "#DD6B55",
                        confirmButtonText: "删除",
                        cancelButtonText:"取消",
                        closeOnConfirm: false
                    }, function () {
                        //执行批量删除
                        $.ajax( {
                            url:'${pageContext.request.contextPath}/sysUser/delGridById.ac',// 跳转到 action
                            data:{
                                ids :ids.toString()
                            },
                            type:'post',
                            cache:false,
                            dataType:'json',
                            success:function(data) {
                                if(data.success){
                                    swal("删除成功！", "您已经删除了这条信息。", "success");
                                    //当前表格刷新
                                    $table.bootstrapTable('refresh');
                                }else{
                                    swal("删除失败！", "未能删除这些信息。", "error");
                                }
                            },
                            error : function() {
                                alert("异常！");
                            }
                        });

                    });
                }else{
                    sweetAlert("无法操作！", "请勾选需要删除的信息!", "error");
                }
            }

            //获取选中的CheckBox
            $("#btn_getCheck").click(function(){
               alert('getSelections: ' + JSON.stringify($table.bootstrapTable('getSelections')));
               alert("客户信息:"+$table.bootstrapTable('getSelections')[0].customer);
            });

            /*
            获取所有选中的CheckBox的主键值 【数组】
             */
            function getSelections() {
                return $.map($table.bootstrapTable('getSelections'), function (row) {
                    return row.id;
                });
            }

            /*
                BootStrapTable CheckBox 状态初始化
             */
            function stateFormatter(value, row, index) {
                if (row.id === 2) {
                    return {
                        disabled: true,
                        checked: true
                    };
                }
                if (row.id === 0) {
                    return {
                        disabled: true,
                        checked: true
                    }
                }
                return value;
            }
            function doLock(obj, user_code)
            {
                var islock = 0;
                if (obj.checked)
                {
                    islock = 1;
                }
                var url = "doLock.ac?user_code=" + user_code + "&islock="
                        + islock;
                $.get(url, function(data)
                {
                });
            }

            ///////////////////////////加载微信用户数据/////////////////////////////////////
            //初始化表格对象
            var $table2 = $('#exampleTablePagination2');
            /*
             获取选中行的相关数据
             */
            $(function () {
                $table2.on('click-row.bs.table', function (e, row, $element) {
                    $('.success').removeClass('success');
                    $($element).addClass('success');
                });
                $('#button2').click(function () {
                    alert('Selected name: ' + getSelectedRow2().customer);
                });
            });
            function getSelectedRow2() {
                var index = $table2.find('tr.success').data('index');
                return $table2.bootstrapTable('getData')[index];
            }
            var identity='${identity}';   //登录账号类型
            $table2.bootstrapTable({
                url: "${pageContext.request.contextPath}/sysUser/showBaseUserGrid.ac",
                method: 'post',
                contentType: "application/x-www-form-urlencoded",//必须的
                dataType: "json",
                pageList:[10, 20, 50, 100],//会根据当前的数据量加载合适的pageList
                height: ($(window).height()) ,
                //cardView:true,//是否自适应手机
                pagination: true, //分页
                // queryParamsType: "limit",
                singleSelect: false,
                cache:false,
                sortName:"customer",
                search: false, //显示搜索框
                showColumns:false,
                showRefresh:false,
                showToggle:false,
                showPaginationSwitch:false,
                smartDisplay:true,
                detailView:false,
                toolbar:"#toolbar2",
                queryParams: queryParams2,//参数
                searchOnEnterKey:true,
                detailFormatter:function(index, row, element){
                    return row.customer;
                },
                sidePagination: "server", //服务端处理分页
                columns: [
                    {
                        visible:false,
                        field:'user_code'
                    },
                    {
                        title:'选择',
                        align:'center',
                        formatter:stateFormatter,
                        checkbox:true
                    },
                    {
                        title: '用户昵称',
                        field: 'person_name',
                        titleTooltip: '点击可以进行排序操作',
                        sortStable:true,
                        align: 'center'
                    },
                    {
                        title: '性别',
                        formatter:function (value, row, index) {
                            if(row.sex==0)
                            {
                                return "未知";
                            }else if(row.sex==1)
                            {
                                return "男";
                            }else if(row.sex==2)
                            {
                                return "女";
                            }
                        },
                        align: 'center'
                    },
                    {
                        title: '手机号',
                        field: 'phone',
                        align: 'center'
                    },
                    {
                        title: '头像',
                        formatter:function (value, row, index) {
                            return '<img src="'+row.cover+'" style="max-height:30px;" />';
                        },
                        align: 'center'
                    },
                    {
                        title: '总积分',
                        formatter:function (value, row, index) {
                            return row.balance_cash/100;
                        },
                        align: 'center'
                    },{
                        title: '可用积分',
                        formatter:function (value, row, index) {
                            return row.balance_90/100;
                        },
                        align: 'center'
                    },

                    {
                        title: '已绑定',
                        formatter:function (value, row, index) {
                            if(row.cover!=null && row.cover!='')
                            {
                                return '<img src="<%=basePath%>resources/plugins/client/images/bmcg_wx.png" width="20" height="20" />';
                            }else if(row.scan_ali_id !=null && row.scan_ali_id!='')
                            {
                                return '<img src="<%=basePath%>resources/plugins/client/images/ali_logo.png" width="20" height="20" />';
                            }else if(row.scan_yi_id !=null && row.scan_yi_id!='')
                            {
                                return '<img src="<%=basePath%>resources/plugins/client/images/yzf_logo.png" width="20" height="20" />';
                            }else if(row.scan_yhk_id !=null && row.scan_yhk_id!='')
                            {
                                return '<img src="<%=basePath%>resources/plugins/client/images/bmcg_yl.png" width="25" height="25" />';
                            }
                        },
                        align: 'center'
                    },
                    {
                        title: '创建时间',
                        formatter:function (value, row, index) {
                            return row.create_time.substring(0,10);
                        },
                        align: 'center'
                    },
                    {
                        title: '操作',
                        align: 'center',
                        formatter:function(value,row,index){
                            var html="";
                            if(identity=="3" && row.phone !=null && row.phone !=''){
                                html+=' <a href="javascript:void(0)" onclick="toIssuedGift('+row.phone+')">远程发劵</a>';
                            }
                           return html;
                        }
                    }
                ]
            });

            /*
             传递的参数
             */
            function queryParams2(params) {
                var temp = {  //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
                    limit: params.limit,  //页面大小
                    offset: params.offset, //页码
                    pageindex:params.pageNumber,
                    q_person_name: $("#q_person_name2").val(),
                    user_balanceType:$("#user_balanceType").val(),
                    startdate: $("#search_startdate").val(),
                    enddate: $("#search_enddate").val(),
                    biz_person_name:$("#biz_person_name").val()
                };
                return temp;
            }
            /*
             搜索按钮
             */
            $("#btn_search2").click(function(){
                $table2.bootstrapTable('refresh', queryParams);
            });

            //修改权限
            function modifyRole(userId){
                var html="";
                $("#roleJson").html("");
                $.ajax({
                    url: '${pageContext.request.contextPath}/role/getAllRoleList.ac',// 跳转到 action
                    data: {},
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        $.ajax({
                            url: '${pageContext.request.contextPath}/role/getRoleListByUser.ac?userId='+userId,// 跳转到 action
                            data: {},
                            type: 'post',
                            cache: false,
                            dataType: 'json',
                            success: function (data2) {
                                var isCheck="";
                                for(var i=0;i<data.length;i++)
                                {
                                    for(var j=0;j<data2.length;j++){
                                        if(data[i].id==data2[j].id)
                                        {
                                            isCheck='checked="checked"';
                                            break;
                                        }else
                                        {
                                            isCheck='';
                                        }
                                    }
                                    html +='<input name="roleNameCheck" '+isCheck+' value="'+data[i].id+'" type="checkbox">'+data[i].text+'<br/>';
                                }
                                $("#roleJson").html(html);
                            },
                            error: function () {
                                parent.layer.msg('加载角色列表失败！');
                            }
                        });

                    },
                    error: function () {
                        parent.layer.msg('加载角色列表失败！');
                    }
                });


                $("#ModifyRoleModal").modal(open);
                $("#roleHidden").val(userId);
            }
            //远程发劵
            function toIssuedGift(phone){

                $("#lbl_phone").html(phone);
                $("#txt_phone").val(phone);
                $("#txt_gift_total").val("");
                $("#txt_gift_remark").val("");
                $("#IssuedGiftModal").modal(open);
            }

            function doSave()
            {
                var isPass = true;
                var phone=$("#txt_phone").val();
                var total=$("#txt_gift_total").val();
                var remark=$("#txt_gift_remark").val();
                if(total==0||total==''){
                    alert("请填写劵额!");
                    isPass=false;
                }
                if (isPass == true)
                {
                    var exp = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
                    if(!exp.test(total)){
                        alert("请输入正确的劵额");
                    }else{
                        var url = "orderStatistics/doIssuedGift.do";
                        $.ajax({
                            type: "post",
                            url: url,
                            data: {phone:phone,total:total,remark:remark}, // 你的formid
                            dataType: 'json',
                            success: function(data) {
                                if(data.isok == true){
                                    alert(data.msg);
                                    toIssuedGift(phone);
                                }else{
                                    alert(data.msg);
                                }
                            }
                        });
                    }

                }
            }

            //提交
            function doRoleSave()
            {

                var chk_value =[];
                $('input[name="roleNameCheck"]:checked').each(function(){
                    chk_value.push($(this).val());
                });

                if(chk_value.length==0 ){
                    alert('请选择数据!');
                    return ;
                }else
                {
                    //alert(chk_value);
                    //alert(chk_value.toString());
                }
                var userId=$("#roleHidden").val();
                $.ajax({
                    url: '${pageContext.request.contextPath}/role/updateUserRole.ac',// 跳转到 action
                    data: {userId:userId,roles:chk_value.toString()},
                    type: 'post',
                    cache: false,
                    dataType: 'json',
                    success: function (data) {
                        //alert(data);
                        parent.layer.msg(data);

                        $("#ModifyRoleModal").modal('hide');
                        $table.bootstrapTable('refresh', queryParams);
                    },
                    error: function () {
                        parent.layer.msg('角色修改失败！');
                    }
                });


            }

            function getSelections2() {
                return $.map($table2.bootstrapTable('getSelections'), function (row) {
                    return row.id;
                });
            }
            //获取选中的CheckBox
            $("#btn_getCheck2").click(function(){
                alert('getSelections2: ' + JSON.stringify($table2.bootstrapTable('getSelections2')));
                alert("客户信息:"+$table2.bootstrapTable('getSelections2')[0].customer);
            });
        </script>
</body>


</html>
